<?php
class Zen_Controller_Admin extends Zend_Controller_Action {

	public function init() {
		$this->_initJQuery();
		$this->_helper->layout->setLayout ( 'admin' );
		if (Zen_User::isLoged ()) {
			$model = new User_Model_Users();
			$acl = Zen_Acl::getInstance();
			$user = $model->getCurrent();
			if (isset($user['lang'])) {
				$lang = $user['lang'];
			} else {
				$cfg = Zend_Registry::get ( 'cnf' );
				$lang = $cfg->languages->default;	
			}
			if (! $acl->isAllowed ( $user ['role'], 'adminka' )) {
				$this->_redirect ( '/error/' );
			}
			Zend_Registry::set('admin_panel_lang', $lang);
		} else {
			$this->_redirect ( '/login/' );
		}
	}
	
	private function _initJQuery() {
		$front = Zend_Controller_Front::getInstance();
		$this->view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
		$this->view->jQuery()
		->enable()->uiEnable()
		->setLocalPath('/cms/res/jui/jquery-1.7.2.min.js')
		->addStylesheet('/cms/res/jui/zen/jquery-ui-1.8.21.custom.css')
		->addJavascriptFile('/cms/res/jui/i18n/jquery.ui.datepicker-ru.js')
		->setUiLocalPath('/cms/res/jui/jquery-ui-1.8.14.custom.min.js');
	}
	

}
